package com.zyit.util;


import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;

import java.util.Random;

public class SendEmail {


    public String SendEmailGo(String a){

        Random random = new Random();
        int randomNumber = random.nextInt(9000) + 1000; // 生成 1000 到 9999 之间的随机整数


        Email email = new SimpleEmail();
//        email.setSmtpPort(465);
        email.setSSL(false);


        email.setHostName("smtp.qq.com");
        email.setAuthentication("2362282011", "fbmficulvaofdhha");
        email.setCharset("UTF-8");

        try {
            email.setFrom("2362282011@qq.com");
            email.setSubject("smtp.qq.com");
            email.setMsg(""+randomNumber+"");
            email.addTo(a);
            email.send();
        } catch (EmailException e) {
            e.printStackTrace();
        }
        return String.valueOf(randomNumber);
    }

}
